import Vue from 'vue'
import VueRouter from 'vue-router'

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const Home = ()=>import("../views/home");
const Cat = ()=>import("../views/cat");
const Cart = ()=>import("../views/cart");
const My = ()=>import("../views/my");

const routes = [
    {
      path:"/",
      redirect:"/home"
    },
    {
      path:"/home",
      component:Home,
      name:"home"
    },
    {
      path:"/cat",
      component:Cat,
      name:"cat"
    },
    {
      path:"/cart",
      component:Cart,
      name:"cart"
    },
    {
      path:"/my",
      component:My,
      name:"my"
    },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
